<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="../template/layout.xhtml">
	<ui:define name="titulo">#{suplementoControle.tituloPagina}</ui:define>

	<ui:define name="frConteudo">
		<h:panelGrid columns="1" border="0" height="100%">
			<!-- bloco de edição -->
			<p:panel header="#{suplementoControle.tituloPagina}"
				rendered="#{suplementoControle.estadoCrud}">
				<h:panelGrid columns="1">
					<f:facet name="header">
						<p:messages id="msgErro" />
					</f:facet>

					<h:panelGrid columns="1" border="0"
						rendered="#{!suplementoControle.estadoFormVazio}">

						<p:tabView cache="false">
							<!-- formulario nota -->
							<p:tab title="Nota">
								<h:form id="formPedido">
									<h:panelGrid columns="1" border="0" height="100%">
										<!-- bloco de edição -->
										<p:panel header="#{suplementoControle.tituloPagina}"
											rendered="#{suplementoControle.estadoCrud}">
											<h:panelGrid columns="1">
												<f:facet name="header">
													<p:messages id="msgErro" />
												</f:facet>

												<h:panelGrid columns="2" border="0">

													<h:outputLabel value="#{msg.suplementoNumSupl}"
														for="numeroSuplemento" />
													<h:inputText id="numeroSuplemento"
														label="#{msg.suplementoNumSupl}"
														value="#{suplementoControle.infoBean.numeroSuplemento}" size="15"
														maxlength="12" required="true"
														requiredMessage="#{msg.suplementoNumSuplRequiredMessage}" />

													<h:outputLabel value="#{msg.suplementoNumDocumento}"
														for="numeroDocumento" />
													<h:inputText id="numeroDocumento"
														label="#{msg.suplementoNumDocumento}"
														value="#{suplementoControle.infoBean.numeroDocumento}" size="15"
														maxlength="12" required="true"
														requiredMessage="#{msg.suplementoNumDocumentoRequiredMessage}" />
														
													<h:outputLabel value="#{msg.suplementoDataDocumento}" for="dataDocumento" />
													<p:calendar id="dataDocumento" label="#{msg.notaDataEmissao}"
														value="#{suplementoControle.infoBean.dataDocumento}"
														required="true"
														requiredMessage="#{msg.suplementoDataDocumentoRequiredMessage}"
														navigator="true" showButtonPanel="true" effect="fold"
														locale="pt" pattern="dd-MM-yyyy" size="15" />

													<h:outputLabel value="#{msg.suplementoDesc}" for="descricao" />
													<h:inputText id="descricao" label="#{msg.suplementoDesc}"
														value="#{suplementoControle.infoBean.descricao}"
														required="true"
														requiredMessage="#{msg.suplementoDescRequiredMessage}" />

													<h:outputLabel value="#{msg.suplementoObs}" for="observacao" />
													<h:inputTextarea id="observacao" label="#{msg.suplementoObs}"
														value="#{suplementoControle.infoBean.observacao}" 
														rows="3" cols="40" />

													<h:outputLabel value="#{msg.statusSuplemento}"
														for="statusSuplemento" />
													<h:selectOneMenu id="statusSuplemento"
														value="#{suplementoControle.infoBean.statusSuplemento}" required="true"
														requiredMessage="#{msg.statusSuplementoRequiredMessage}"
														style="with:700px">
														<f:selectItems
															value="#{statusSuplementoControle.itemsAvailableSelectOne}" />
													</h:selectOneMenu>

													<h:outputLabel value="#{msg.fornecedorNome}"
														for="fornecedor" />
													<h:selectOneMenu id="fornecedor"
														value="#{suplementoControle.infoBean.fornecedor}" required="true"
														requiredMessage="#{msg.fornecedorNomeRequiredMessage}"
														style="with:700px">
														<f:selectItems
															value="#{fornecedorControle.itemsAvailableSelectOne}" />
													</h:selectOneMenu>

													<f:facet name="footer">
														<h:panelGroup>
															<center>
																<h:commandButton id="salvarButton"
																	value="#{msg.salvarButton}"
																	action="#{suplementoControle.gravar}"
																	rendered="#{suplementoControle.estadoAdicionar}" >
																	<f:ajax execute="@form" render=":formPedido" />
																</h:commandButton>
																<h:commandButton id="alterarButton"
																	value="#{msg.alterarButton}"
																	action="#{suplementoControle.gravar}"
																	rendered="#{suplementoControle.estadoActualizar}" />
																<h:commandButton id="eliminarButton"
																	value="#{msg.eliminarButton}"
																	action="#{suplementoControle.excluir}"
																	rendered="#{suplementoControle.estadoEliminar}"
																	onclick="if(!confirm('Confirma a exclusão do registo?')) return false;" />
																<h:commandButton id="limparButton"
																	value="#{msg.limparButton}" type="reset"
																	rendered="#{suplementoControle.estadoAdicionar}" />
																<h:commandButton id="cancelarButton"
																	value="#{msg.cancelarButton}"
																	action="#{suplementoControle.voltar}" immediate="true" />
															</center>
														</h:panelGroup>
													</f:facet>
												</h:panelGrid>
											</h:panelGrid>
										</p:panel>
									</h:panelGrid>
								</h:form>
							</p:tab>
							<!-- fim formulario nota -->
							
							<!-- formulario items da nota -->
							<p:tab title="Items">
								<h:form id="formItem">
								</h:form>
							</p:tab>
							<!-- fim do formulario items do pedido -->
							
						</p:tabView>
					</h:panelGrid>
					
					<!-- formulario de listagem -->
					<h:form id="formListagem">
					</h:form>
					<!-- fim formulario de listagem -->
					
				</h:panelGrid>
			</p:panel>
			<!-- fim do bloco de edição -->
			<h:form>
				<center>
					<h:commandLink action="#{suplementoControle.voltar}" immediate="true"
						value="#{msg.geralLinkListaRegistos}" />
				</center>
			</h:form>
		</h:panelGrid>
	</ui:define>
</ui:composition>
</html>